package com.leyantech.ecp.agenx.web.testwin;

import com.leyantech.ai.DialogueReplyContext;
import com.leyantech.ai.DialogueReplyV2;
import com.leyantech.ai.FAQDetail;
import com.leyantech.ai.H2HDetail;
import com.leyantech.ai.PolicyDetail;
import com.leyantech.ai.WaitDetail;
import com.leyantech.ai.WorkFlowDetail;
import com.leyantech.utility.Logger;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.google.gson.annotations.JsonAdapter;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 测试窗消息回复.
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@JsonSerialize(using = TestWinReplySerializer.class)
@Builder
@JsonAdapter(TestWinJsonAdapter.class)
public class TestWinReply {

  private static final Logger LOGGER = new Logger(TestWinReply.class);

  private static final ObjectMapper objectMapper = new ObjectMapper();

  private DialogueReplyV2 dialogueReplyV2;

  private DialogueReplyContext dialogueReplyContext;

  private PolicyDetail policyDetail;

  private FAQDetail faqDetail;

  private WorkFlowDetail workFlowDetail;

  private H2HDetail h2HDetail;

  private WaitDetail waitDetail;

  private Long timestamp;

  private transient Integer testWinLimitReason;

  private transient boolean testWinLimit;

  /**
   * 序列化为json给前端.
   */
  public String toJson() {
    try {
      return objectMapper.writeValueAsString(this);
    } catch (JsonProcessingException e) {
      LOGGER.warn(e, "jackson to json fails. {}", this);
      return "";
    }
  }

}


